package com.realgodo.site.entity.relation;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.realgodo.site.entity.IdEntity;
import com.realgodo.site.entity.space.Space;

/**
 * @author bijiqiang E-mail: bijiqiang@gmail.com
 * @version 创建时间：2009-12-13下午03:44:24
 * @since jdk1.5
 * @version 0.1
 */
@Entity(name="Relation")
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name="relation")
public class Relation extends IdEntity {
	/**关系状态：新申请*/
	public static final int STATUS_NEW=0;
	/**关系状态：同意*/
	public static final int STATUS_AGREE=1;
	/**关系状态：拒绝*/
	public static final int STATUS_REJECT=-1;

	private static final long serialVersionUID = -7254292843224431698L;
	
	private int status=STATUS_NEW;
	
	public static final int STATUS_NOT_PASS = STATUS_REJECT;
	public static final int STATUS_PASS = STATUS_AGREE;
	
	private Space sender;
	private Space receiver;
	
	@Column(name = "status", insertable = true, updatable = true)
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	@OneToOne()
	@JoinColumn(name = "sender_id", referencedColumnName = "id", nullable = false)
	public Space getSender() {
		return sender;
	}
	public void setSender(Space sender) {
		this.sender = sender;
	}
	
	@OneToOne()
	@JoinColumn(name = "receiver_id", referencedColumnName = "id", nullable = false)
	public Space getReceiver() {
		return receiver;
	}
	public void setReceiver(Space receiver) {
		this.receiver = receiver;
	}
	
	

}
